//1.导入Vue和VueRouter的包
import Vue from 'vue'
import VueRouter from 'vue-router'
import LogisticsHome from "@/components/LogisticsHome"
import FrontPage from "@/components/user/FrontPage"
import UserSending from "@/components/user/UserSending"
import ViewLogistics from "@/components/user/ViewLogistics"
import UserLogin from "@/components/login/UserLogin"
import UserRegister from "@/components/login/UserRegister"
import AdministratorHome from "@/components/administrator/AdministratorHome"
import LogisticsState from "@/components/administrator/LogisticsState"
import LogisticsMap from "@/components/LogisticsMap"
import LogisticsTransfer from "@/components/administrator/LogisticsTransfer"
//2.调用Vue.use()函数，把VueRouter安装为Vue的插件
Vue.use(VueRouter)

const routes = [
  {
    path: '*',
    redirect: '/login'//重定向
  },
  {
    path: '/login',
    name: 'UserLogin',
    component:UserLogin
  },
  {
    path: '/register',
    name: 'UserRegister',
    component:UserRegister
  },
  {
    path: '/home',
    name: 'LogisticsHome',
    //组件已经导入，直接写组件名
    component: LogisticsHome,//路由名字
    children: [
      {
        path: '/frontpage',
        component: FrontPage,
      },
      {
        path: '/usersending',
        component: UserSending,
      },
      {
        path: '/viewlogistics',
        component: ViewLogistics,
      },
      {
        path: '/logisticsMap',
        component: LogisticsMap,
      },
    ]
  },
  {
    path: '/administratorHome',
    name: 'AdministratorHome',
    //组件已经导入，直接写组件名
    component:AdministratorHome ,//路由名字
    children:[
      {
        path: '/logisticsState',
        component: LogisticsState,
      },
      {
        path: '/adFrontpage',
        component: FrontPage,
      },
      {
        path: '/logisticsTransfer',
        component: LogisticsTransfer,
      },
    ]
  }


]
//3.创建路由的实例对象
const router = new VueRouter({
  mode: 'history',
  routes
})
//4.向外共享路由的实例对象
export default router